package org.suyisen.feng.core.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.suyisen.feng.core.dto.Cifuser;
import org.suyisen.feng.core.mapper.CifuserMapper;
import org.suyisen.feng.core.service.CifuserService;

@Service
public class CifuserServiceImpl implements CifuserService {

	
	@Autowired
	CifuserMapper cifuserMapper;
	
	@Override
	public String createCifuser(Cifuser cifuser) {
		org.suyisen.feng.core.domain.Cifuser user = new org.suyisen.feng.core.domain.Cifuser();
		BeanUtils.copyProperties(cifuser, user);
		cifuserMapper.createCifuser(user);
		return "SUCCESS";
	}

	@Override
	public List<Cifuser> queryAllCifusers() {
		List<org.suyisen.feng.core.domain.Cifuser> list = cifuserMapper.queryAllCifusers();
		List<Cifuser> cList = new ArrayList<>();
		Iterator<org.suyisen.feng.core.domain.Cifuser> iterator = list.iterator();
		while(iterator.hasNext()) {
			Cifuser user = new Cifuser();
			BeanUtils.copyProperties(iterator.next(), user);
			cList.add(user);
		}
		
		return cList;
	}

	@Override
	public Cifuser queryOneCifuser(String custid) {
		org.suyisen.feng.core.domain.Cifuser one = cifuserMapper.queryOneCifusers(custid);
		Cifuser user = new Cifuser();
		BeanUtils.copyProperties(one, user);
		return user;
	}

	@Override
	public Cifuser queryTheOneCifuser() {
		org.suyisen.feng.core.domain.Cifuser one = cifuserMapper.queryTheOneCifusers();
		Cifuser user = new Cifuser();
		BeanUtils.copyProperties(one, user);
		return user;
	}

}
